package com.aliware.edas;

import com.alibaba.boot.hsf.annotation.HSFProvider;
import com.aliyun.api.FlightDelay;
import com.aliyun.model.FlightInfo;
import com.aliyun.model.Passenger;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

@HSFProvider(serviceInterface = FlightDelay.class, serviceVersion = "1.1.0")
public class FlightDelayImpl implements FlightDelay {
    @Override
    public FlightInfo flightInformation(String flightNumber) {
        FlightInfo flightInfo = new FlightInfo();
        flightInfo.setNumber(flightNumber);
        flightInfo.setOrigin("西安");
        flightInfo.setOriginPY("XIY");
        flightInfo.setTerminus("哈尔滨");
        flightInfo.setOriginPY("HRB");
        flightInfo.setState("延误待定");
        flightInfo.setWhereabouts("出港");
        flightInfo.setPlannedDepartureime(new Date());
        flightInfo.setEto(new Date());
        flightInfo.setCauseOfDelay("天气原因");
        flightInfo.setAirplaneNumber("B1234");
        flightInfo.setTotalPassenger(6);

        List<Passenger> passengers = new ArrayList();
        for(int i = 0, len = flightInfo.getTotalPassenger(); i<len; i++){
            Passenger passenger = new Passenger();
            passenger.setName("测试旅客"+i);
            passenger.setNumber(String.valueOf(i));
            passenger.setSex(new Random().nextInt(3) % 2 == 0? "男":"女");
            passenger.setFlightNumber(flightNumber);
            passenger.setPosition(new Random().nextInt(3) % 2 == 0? "头等":"普通");
            passenger.setAge(new Random().nextInt(60));
            passengers.add(passenger);
        }
        flightInfo.setPassengers(passengers);
        return flightInfo;
    }
}
